package site.potatoblog.threadpool.manager.builder.impl;

import site.potatoblog.threadpool.manager.builder.Builder;
import site.potatoblog.threadpool.manager.vo.ThreadPoolDetailInfo;

import java.util.Date;

public class ThreadPoolDetailInfoBuilder implements Builder<ThreadPoolDetailInfo> {
    private int corePoolSize;
    private int maxPoolSize;
    private int keepAliveSeconds;
    private int queueCapacity;
    private int activeCount;
    private long completedTaskCount;
    private int largestPoolSize;
    private int rejectCount;
    private long taskCount;
    private int poolSize;
    private int queueSize;
    private int queueRemainingCapacity;
    private boolean allowCoreThreadTimeOut;
    private String queueType;
    private String appName;
    private String threadPoolName;
    private Date currentTime;
    private String threadFactoryType;
    private String rejectHandlerType;

    private ThreadPoolDetailInfoBuilder(){}

    public ThreadPoolDetailInfoBuilder setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setMaxPoolSize(int maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setKeepAliveSeconds(int keepAliveSeconds) {
        this.keepAliveSeconds = keepAliveSeconds;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setQueueCapacity(int queueCapacity) {
        this.queueCapacity = queueCapacity;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setActiveCount(int activeCount) {
        this.activeCount = activeCount;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setCompletedTaskCount(long completedTaskCount) {
        this.completedTaskCount = completedTaskCount;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setLargestPoolSize(int largestPoolSize) {
        this.largestPoolSize = largestPoolSize;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setRejectCount(int rejectCount) {
        this.rejectCount = rejectCount;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setTaskCount(long taskCount) {
        this.taskCount = taskCount;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setPoolSize(int poolSize) {
        this.poolSize = poolSize;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setQueueSize(int queueSize) {
        this.queueSize = queueSize;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setQueueRemainingCapacity(int queueRemainingCapacity) {
        this.queueRemainingCapacity = queueRemainingCapacity;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {
        this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setQueueType(String queueType) {
        this.queueType = queueType;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setAppName(String appName) {
        this.appName = appName;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setThreadPoolName(String threadPoolName) {
        this.threadPoolName = threadPoolName;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setCurrentTime(Date currentTime) {
        this.currentTime = currentTime;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setThreadFactoryType(String threadFactoryType) {
        this.threadFactoryType = threadFactoryType;
        return this;
    }

    public ThreadPoolDetailInfoBuilder setRejectHandlerType(String rejectHandlerType) {
        this.rejectHandlerType = rejectHandlerType;
        return this;
    }

    public static ThreadPoolDetailInfoBuilder create(){
        return new ThreadPoolDetailInfoBuilder();
    }


    @Override
    public ThreadPoolDetailInfo build() {
        return new ThreadPoolDetailInfo( corePoolSize, maxPoolSize,  keepAliveSeconds,  queueCapacity,  activeCount,  completedTaskCount,  largestPoolSize,  rejectCount,  taskCount,  poolSize,  queueSize,  queueRemainingCapacity,  allowCoreThreadTimeOut, queueType,  appName, threadPoolName, currentTime,threadFactoryType,rejectHandlerType);
    }
}
